package com.jinzhi.jzweb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzapi.utils.JWTUtil;
import com.jinzhi.jzweb.dao.JazUserAuntDao;
import com.jinzhi.jzweb.domain.JazUserAuntDO;
import org.springframework.stereotype.Service;

import com.jinzhi.jzweb.dao.JazAuntRefereeDao;
import com.jinzhi.jzweb.domain.JazAuntRefereeDO;
import com.jinzhi.jzweb.service.JazAuntRefereeService;
import com.jinzhi.common.base.CoreServiceImpl;

/**
 * 
 * <pre>
 * 阿姨推荐表
 * </pre>
 * <small> 2024-05-20 09:27:04 | Long</small>
 */
@Service
public class JazAuntRefereeServiceImpl extends CoreServiceImpl<JazAuntRefereeDao, JazAuntRefereeDO> implements JazAuntRefereeService {

    private final JazUserAuntDao jazAuntRefereeDao;

    public JazAuntRefereeServiceImpl(JazUserAuntDao jazAuntRefereeDao){
        this.jazAuntRefereeDao = jazAuntRefereeDao;
    }

    /**
     * 推荐列表
     * @param jazAuntRefereeDO
     * @return
     */
    @Override
    public Result<?> auntRefereeList(JazAuntRefereeDO jazAuntRefereeDO) {
        Long userId = JWTUtil.getUser().getId();
        Page<JazAuntRefereeDO> page = new Page<>(jazAuntRefereeDO.getCurrent(), jazAuntRefereeDO.getSize());
        Page<JazAuntRefereeDO> pageList = this.selectPage(page, new EntityWrapper<JazAuntRefereeDO>().eq("referee_id", userId));
        if(null!=pageList.getRecords() && !pageList.getRecords().isEmpty()){
            pageList.getRecords().forEach(record->{
                //查询阿姨寸照
                JazUserAuntDO jazUserAuntDO = new JazUserAuntDO();
                jazUserAuntDO.setSysUserid(record.getAuntId());
                JazUserAuntDO jazUserAuntDO1 = jazAuntRefereeDao.selectOne(jazUserAuntDO);
                record.setJazUserAuntDO(jazUserAuntDO1);
            });
        }

        return Result.ok(pageList);
    }
}
